<?php

// $get=$_GET['id']? $_GET['id']:'';

require_once '../config.php';
require_once '../functions.php';



function make_add()
{
    if (empty($_POST['name'])) {
        $GLOBALS['message']="请填写作者名字";
    }
    
    if (empty($_POST['publisher'])) {
        $GLOBALS['message']="请填写出版社";
    }
    if (empty($_POST['pages'])) {
        $GLOBALS['message']="请填写页数";
    }

    if (empty($_POST['price'])) {
        $GLOBALS['message']="请填写价格";
    }
    if (empty($_POST['ISBN'])) {
        $GLOBALS['message']="请填写日期";
    }
    if (empty($_POST['produce'])) {
        $GLOBALS['message']="请填写文化";
    }
    if (empty($_POST['pad'])) {
        $GLOBALS['message']="请填写装帧";
    }
    if (empty($_POST['com_data'])) {
        $GLOBALS['message']="请填写日期";
    }
    if (empty($_POST['ISBN'])) {
        $GLOBALS['message']="请填写ISBN";
    }

    $name= $_POST['name'];
    $publisher= $_POST['publisher'];
    $pages = $_POST['pages'];
    $price = $_POST['price'];
    $ISBN=$_POST['ISBN'];
    $produce = $_POST['produce'];
    $pad=$_POST['pad'];
    $com_data=$_POST['com_data'];
   
   

    // $rows =book_execute("insert into list (id,publisher,name,,synopsis,com_data,list_isbn,)values (null,'{$publisher}','{$name}','{$nick}','{$pages}','{$com_data}','{$ISBN}');");
    $rows = book_execute("insert into comm values (null,'{$name}','{$publisher}','{$pages}','{$price}','{$pad}','{$produce}','{$com_data}','{$ISBN}')");




    // var_dump($rows);
    // insert into make values(null,'天天','175@qq.com','你好','撒旦法沙发撒旦法','2020-03-19 17:15:32',151);
    $GLOBALS['success'] = $rows > 0;
    $GLOBALS['message'] = $rows <= 0 ? '添加失败！' : '添加成功！';
}



    if ($_SERVER['REQUEST_METHOD']==='POST') {
        make_add();
    }




?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>Users &laquo; Admin</title>
  <link rel="stylesheet" href="/static/assets/vendors/bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="/static/assets/vendors/font-awesome/css/font-awesome.css">
  <link rel="stylesheet" href="/static/assets/vendors/nprogress/nprogress.css">
  <link rel="stylesheet" href="/static/assets/css/admin.css">
  <script src="/static/assets/vendors/nprogress/nprogress.js"></script>
</head>
<body>
  <script>NProgress.start()</script>

  <div class="main">

  <?php include 'inc/navbar_admin.php'; ?>

    <div class="container-fluid">
      <div class="page-title">
        <h1>书的详细信息</h1>
      </div>
      <?php if (isset($message)): ?>
     <?php if ($success):?>
              <!-- 有错误信息时展示 -->
      <div class="alert alert-success">
        <strong>成功！</strong><?php echo $message;?>
      </div>
    <?php else:?>
       <div class="alert alert-danger">
        <strong>错误！</strong><?php echo $message;?>
      </div>
     <?php endif ?>
     <?php endif ?>
      <div class="row">
        <div class="col-md-6">
            <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
            <div class="form-group">
              <label for="name">作者</label>
              <input id="name" class="form-control" name="name" type="text" placeholder="作者">
            </div>
            <div class="form-group">
              <label for="publisher">出版社</label>
              <input id="publisher" class="form-control" name="publisher" type="text" placeholder="出版社">
            </div>
            <div class="form-group">
              <label for="pages">页数</label>
              <input id="pages" class="form-control" name="pages" type="text" placeholder="页数">
            </div>
            <div class="form-group">
              <label for="price">价格</label>
              <input id="price" class="form-control" name="price" type="text" placeholder="价格">
            </div>
            <div class="form-group">
              <label for="produce">文化</label>
              <input id="produce" class="form-control" name="produce" type="text" placeholder="文化平台">
            </div>
            <div class="form-group">
              <label for="pad">装帧</label>
              <input id="pad" class="form-control" name="pad" type="text" placeholder="装帧">
            </div>
           
            <div class="form-group">
              <label for="com_data">日期</label>
              <input id="com_data" class="form-control" name="com_data" type="date" placeholder="日期">
            </div>
            <div class="form-group">
              <label for="ISBN">ISBN</label>
              <input id="ISBN" class="form-control" name="ISBN" type="text" placeholder="ISBN">
            </div>
            <div class="form-group">
              <button class="btn btn-primary" type="submit">添加</button>
              <a href="/admin/sentence.php" class="btn btn-primary" type="submit">返回</a>
            </div>
          </form>
         
        </div>
       
      </div>
    </div>
  </div>
  
  <?php include 'inc/sidebar.php'; ?>
  <script src="/static/assets/vendors/jquery/jquery.js"></script>
  <script src="/static/assets/vendors/bootstrap/js/bootstrap.js"></script>
  <script>NProgress.done()</script>
</body>
</html>
